package com.learn.redis.test;

import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;

/**
 * @author DYZ
 * @date 2021/8/25
 */
public class RedisTestString {

    Jedis jedis;

    @Before
    public void setUp() {
        jedis = new Jedis("192.168.2.23", 6379);
    }

    @Test
    public void ping() {
        //-----添加数据----------
        jedis.set("name", "Don");
        System.out.println(jedis.get("name"));

        //-----修改数据-----------
        //1、在原来基础上修改
        jedis.append("name", "Redis");
        System.out.println(jedis.get("name"));

        //2、直接覆盖原来的数据
        jedis.set("name", "Jedis");
        System.out.println(jedis.get("name"));

        //3、删除key对应的记录
        jedis.del("name");
        System.out.println(jedis.get("name"));

        jedis.mset("name", "Don", "learn", "Redis");
        System.out.println(jedis.mget("name", "learn"));
    }

}
